

def dict_2_sql(dicts,db):
    #insert into table (字段) values（值
    names=','.join(dicts.keys())
    values=','.join(dicts.values())
    sql='insert into '+db+"("+names+") values("+values+")"
    return sql
if __name__ == '__main__':
    test = {
        'a': '1',
        'b': '2',
        'c': '3',
        'd': '4',
    }
    sql=dict_2_sql(test,"dbname")
    print(sql)

